<template>
  <div>
    <ul>
      <li v-for="item in items" :key="item.id">
        {{item.name}} - {{item.quantity}}
      </li>
    </ul>
    <div>总价为：{{totalPrice}}</div>
  </div>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
export default {
  computed: {
    ...mapState('cart', ['items']),
    ...mapGetters('cart', ['totalPrice'])
  },
}
</script>